package cn.chenchendemospringboot.stock_demo.controller;

import cn.chenchendemospringboot.stock_demo.entity.Inventory;
import cn.chenchendemospringboot.stock_demo.service.Impl.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("/inventory")
public class InventoryController {
    @Autowired
    private InventoryService inventoryService;
    @PostMapping("/insert")
    public boolean createInventory(@RequestBody Inventory inventory) {


        // 设置具体的字段值
        inventory.setProductName("phone");
        inventory.setPrice(BigDecimal.valueOf(12.8));
        inventory.setStockQuantity(3);

        // 调用Service层的saveOrder方法
        return inventoryService.saveInventory(inventory);
    }
}
